import request from '@/config/request.js'
import uplodefile from '@/config/uplodefile.js'




//登录
export const login = (code, name) => request({ url: '/user/login?code=' + code + '&nickname=' + name, method: 'GET' })
//更新用户头像
export const sendHeadImage = (pid, url) => uplodefile({
	url: '/user/avatar?pid=' + pid,
	filePath: url,
	name: 'file',
})
//修改用户资料
export const changeUserInfo = data => request({ url: '/user', method: 'PUT', data: data })

//个人动态信息
export const onesMomentList = (pageSize, pid) => request({
	url: '/dynamic/list/userId?pageNum=1&pageSize=' + pageSize + '&userId=' + pid,
	method: 'GET'
})
// export const login = (code,url,data)=> uplodefile({
// 	url: '/user/login?code=' + code,
// 	filePath: url,
// 	name: 'file',
// 	formData: data
// })
//个人运动信息
export const onesSportList = pid => request({
	url: '/motion/list?userId=' + pid,
	method: 'GET'
})


/**
 * 运动接口
 */

//上传运动数据
export const upSportMes = data => request({ url: '/motion', method: 'POST', data: data })

/**
 * 排行榜接口
 */
export const rankingList = (distance) => request({ 
	url: '/motion/overt/list?distance=' + distance, 
	method: 'GET',
	})




/**
 * 运动圈接口
 */

//动态列表
export const momentList = (userId,pageNum, pageSize) => request({
 url: '/dynamic/list?userId='+ userId +'&pageNum=' + pageNum + '&pageSize=' +
		pageSize, method: 'GET' 
})
//发表评论
export const sendComment = data => request({ url: '/comment ', method: 'POST', data: data })
//点赞
export const giveThumbs = (userId,data) => request({ url: '/dynamic/dynamic/' + userId, method: 'PUT', data: data })
//发表动态
export const sendMoment = data => request({ url: '/dynamic ', method: 'POST', data: data })
//上传动态图片
export const sendMomentImg = (url, data) => uplodefile({
	url: '/dynamic/upload',
	filePath: url,
	name: 'file',
	formData: data,
})

/**
 * 健身房接口
 */
// 健身房列表
export const gymList = (pageNum, pageSize) => request({
	url: '/gym/list?pageNum=' + pageNum + '&pageSize=' + pageSize,
	method: 'GET'
})
// 健身房详情
export const gymDetail = id => request({
	url: '/gym/' + id,
	method: 'GET'
})
// 运动器材详情
export const gymEq = id => request({
	url: '/gym/equipment/' + id,
	method: 'GET'
})

/**
 * 食物百科接口
 */
// 食物百科一级分类
export const foodTypeList = () => request({
	url: '/food/type/list',
	method: 'GET'
})
// 食物百科二级分类
export const foodDetailTypeByFoodTypeIdList = (foodTypeId) => request({
	url: '/food/detail/type/list/' + foodTypeId,
	method: 'GET'
})
// 食物百科详情列表
export const foodDetailByTypeIdList = (typeId) => request({
	url: '/food/detail/list/' + typeId,
	method: 'GET'
})
// 食物百科详情列表(根据食物名模糊查询)
export const foodDetailByFoodNameList = (foodName) => request({
	url: '/food/detail/foodName?foodName=' + foodName,
	method: 'GET'
})
// 食物百科详情
export const foodDetailByFoodId = (foodId) => request({
	url: '/food/detail/' + foodId,
	method: 'GET'
})
